# -*- coding: utf-8 -*-
from __future__ import absolute_import

import os
import subprocess
#from .models import Lession
from celery import shared_task

Base_dir = os.path.dirname(os.path.dirname(__file__))
Ffmpeg_path = "/usr/local/sbin/ffmpeg"
#Vedio_format_full = "-y"
Vedio_format_smooth = "-ab 56 -ar 22050 -r 18 -b 500 -s 640*360 -y"

@shared_task
def deal_vedio(video,suffix):
	#lession = Lession.objects.get(id=id)#获取原视频地址
	original_vedio_path = os.path.join(Base_dir, "e:/Demo/templates/video/"+video+'.'+suffix)#原视频地址，测试
	smooth_vedio_path = os.path.join(Base_dir, "e:/Demo/templates/video/"+video+".flv")#转换后的流程版地址
	#full_vedio_path = os.path.join(Base_dir, "/home/Maizhi/templates/video/"+video+"_full.flv")#转换后的高清版地址
	convert_cmd = Ffmpeg_path + ' -i ' + original_vedio_path + ' ' + Vedio_format_smooth + ' ' + smooth_vedio_path
	subprocess.Popen(convert_cmd, shell=True, stdout=subprocess.PIPE).wait()
    #convert_cmd = Ffmpeg_path + ' -i ' + original_vedio_path + ' ' + Vedio_format_full + ' ' + full_vedio_path
    #subprocess.Popen(convert_cmd, shell=True, stdout=subprocess.PIPE).wait()
